﻿using University.Workshop.DataAccess;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using University.Workshop.Model;
using University.Workshop.Business;

namespace University.Workshop.Tests
{
    
    
    /// <summary>
    ///This is a test class for ClientRegistrationTest and is intended
    ///to contain all ClientRegistrationTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ClientRegistrationTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for AddClient
        ///</summary>
        [TestMethod()]
        [ExpectedException(typeof(ArgumentException))]
        public void AddClientBlankTest()
        {
            string fullName = "";
            string id = "";
            string telephone = "";

            string organizacion = "";
            string celular = "";
            string email = "";
            string fechaNacimiento = "";
            string fax = "";
            string pais = "";
            string sexo = "";

            Client client = new Client { FullName = fullName, ClientId = id, Telephone = "telephone"};  // TODO: Initialize to an appropriate value
            ClientManager.ValidateForRegistration(fullName, id, telephone, organizacion, celular, email, fechaNacimiento, fax, pais, sexo);
        }

        /// <summary>
        ///A test for AddClient
        ///</summary>
        [TestMethod()]
        [ExpectedException(typeof(ArgumentException))]
        public void AddClientTest1()
        {
            Client client = new Client (); 
            ClientManager.ValidateForRegistration(client.FullName, client.ClientId, client.Telephone, client.Organization, client.Cell, client.Email, client.Birthday, client.Fax, client.Country, client.Gender);
        }

        /// <summary>
        ///A test for AddClient
        ///</summary>
        ///
        
        [TestMethod()]
        public void AddClientTest2()
        {
            Random random = new Random(DateTime.Now.Millisecond);
            string fullName = "Daniel"; // +random.Next(int.MaxValue);
            string id = "123456";
            string telephone = "72123456";

            string organizacion = "1";
            string celular = "2";
            string email = "daniel@" + random.Next(1254) + "gmail.com";
            string fechaNacimiento = "4-4-4";
            string fax = "5";
            string pais = "6";
            string sexo = "7";

            ClientManager.ValidateForRegistration(fullName, id, telephone, organizacion, celular, email, fechaNacimiento, fax, pais, sexo);
        }
        

        [TestMethod()]
        [ExpectedException(typeof(ArgumentException))]
        public void AddClientTest3()
        {
            Client client = null;
            ClientRegistration.AddClient(client);
        }

    }
}
